const router = require( 'koa-router' )();
const path = require( 'path' );
const fs = require( 'fs' );

const appSetting = require( '../setting' );

const headers = { 'Content-Type': 'application/json', 'Encoding': 'utf8' };

const getAPIStatisticsByHour = ( apiName ) => {

}

const getAPIStatisticsByDay = () => {

}

const getAPIStatistics = async function ( ctx, next ) {

    let userId = ctx.request.cookies.userId;
    let apiName = ctx.query.apiName;
    let unit = ctx.query.unit;
    let count = ctx.query.count;

    if ( !apiName || !unit || count === undefined ) {
        ctx.body = { code: 1, msg: '参数缺失' };
    }

    if ( unit !== 'hour' && unit !== 'day' || isNaN( count ) ) {
        ctx.body = { code: 1, msg: '参数错误' };
    }

    let result = [];
    let appTimeZone = appSetting.getSetting( 'app.timezone' );

   

}

router.get( '/api', getAPIStatistics );

module.exports = router;
